package model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.OneToMany;
import javax.persistence.JoinColumn;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.GenericGenerator;

import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name="groups")
public class Group {

    int id;
    String name;
    int id_faculty = 0;
    private Set<Student> students = new HashSet<Student>(0);
    private Faculty faculty;

    @Id
    @GeneratedValue(generator="increment")
    @GenericGenerator(name="increment", strategy = "increment")
    @Column(name="id")
    public int getId(){
        return id;
    }
    public void setId(int id){
        this.id = id;
    }

    @Column(name = "name")
    public String getName(){
        return name;
    }

    public void setName(String name){
        this.name = name;
    }

    @OneToMany(mappedBy="group")
    public Set<Student> getStudents() {
        return students;
    }

    public void setStudents(Set<Student>  students){
        this.students = students;
    }

    @ManyToOne
    @JoinColumn(name = "id_faculty")
    public Faculty getFaculty(){
        return faculty;
    }

    public void setFaculty(Faculty faculty){
        this.faculty = faculty;
    }

}
